<template>
  <div>
    <swiper :options="swiperOptions">
      <swiper-slide v-for="(page, index) of pages" :key="index">
        <div class="icons">
          <div class="icons-img" v-for="item in page" :key="item.id">
            <img :src="item.imgUrl" class="icons-img-content" />
            <p class="icons-img-desc">{{ item.desc }}</p>
          </div>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
export default {
  props: {
    list: Array
  },
  data() {
    return {
      swiperOptions: {}
    }
  },
  computed: {
    pages() {
      const pages = []
      this.list.forEach((item, i) => {
        const page = Math.floor(i / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '~styles/mixins.styl';
.icons {
  width: 100%;
  display: flex;
  overflow: hidden;
  flex-wrap: wrap;

  .icons-img {
    overflow: hidden;
    width: 25%;
    box-sizing: border-box;
    padding: 10px;
    text-align: center;

    .icons-img-content {
      width: 1.1rem;
      height: 1.1rem;
    }

    .icons-img-desc {
      margin: 5px 0;
      color: #333;
      text-align: center;
      ellipsis();
    }
  }
}
</style>
